// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FeesTracker.cs" company="Open Trader">
//   Copyright (c) David Denis (david.denis@systemathics.com)
// </copyright>
// <summary>
//   |  Open Trader - The Open Source Systematic Trading Platform
//   |
//   |  This program is free software: you can redistribute it and/or modify
//   |  it under the terms of the GNU General Public License as published by
//   |  the Free Software Foundation, either version 2 of the License, or
//   |  (at your option) any later version.
//   |
//   |  This program is distributed in the hope that it will be useful,
//   |  but WITHOUT ANY WARRANTY; without even the implied warranty of
//   |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   |  GNU General Public License for more details.
//   |
//   |  You should have received a copy of the GNU General Public License
//   |  along with this program.  If not, see http://www.gnu.org/licenses
//   |
//   |  Up to date informations about Open Trader can be found at :
//   |    http://opentrader.org
//   |    http://opentrader.codeplex.com
//   |
//   |  For professional services, please visit us at :
//   |    http://www.systemathics.com
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Org.OpenTrader.Framework.Forge
{
    #region Using Directives

    using System.ComponentModel;

    using Org.OpenTrader.Framework.Forge.Interfaces;

    #endregion

    /// <summary>
    /// The fees tracker.
    /// </summary>
    public abstract class FeesTracker : IFeesTracker
    {
        #region Constants and Fields

        /// <summary>
        /// Ack Fees
        /// </summary>
        private double ackFees;

        /// <summary>
        /// Cancel Fees
        /// </summary>
        private double cancelFees;

        /// <summary>
        /// Execution Fees
        /// </summary>
        private double executionFees;

        /// <summary>
        /// Cost Fees
        /// </summary>
        private double fees;

        /// <summary>
        /// Modify Fees
        /// </summary>
        private double modifyFees;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="FeesTracker"/> class. 
        /// Fees tracker Constructor
        /// </summary>
        /// <param name="instrument">
        /// not null
        /// </param>
        public FeesTracker(IInstrument instrument)
        {
            // Instrument Expo
            this.Instrument = instrument;

            // Fees to apply
            this.ExecutionFees = 0.0001;
            this.CancelFees = 0.0;
            this.ModifyFees = 0.0;
            this.AckFees = 0.0;

            // Fees cost
            this.Fees = 0.0;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets AckFees.
        /// </summary>
        [Category("Fees")]
        public double AckFees
        {
            get
            {
                return this.ackFees;
            }

            protected set
            {
                this.ackFees = value > 0.0 ? value : 0.0;
            }
        }

        /// <summary>
        /// Gets or sets CancelFees.
        /// </summary>
        [Category("Fees")]
        public double CancelFees
        {
            get
            {
                return this.cancelFees;
            }

            protected set
            {
                this.cancelFees = value > 0.0 ? value : 0.0;
            }
        }

        /// <summary>
        /// Gets ExecutionFees.
        /// </summary>
        [Category("Fees")]
        public double ExecutionFees
        {
            get
            {
                return this.executionFees;
            }

            protected set
            {
                this.executionFees = value > 0.0 ? value : 0.0;
            }
        }

        /// <summary>
        /// Gets CostFees.
        /// </summary>
        [Category("Fees")]
        [ReadOnly(true)]
        public double Fees
        {
            get
            {
                return this.fees;
            }

            protected set
            {
                this.fees = value > 0.0 ? value : 0.0;
            }
        }

        /// <summary>
        /// Gets or sets Instrument.
        /// </summary>
        public IInstrument Instrument { get; set; }

        /// <summary>
        /// The order event delegate.
        /// </summary>
        public abstract InventoryEventDelegate InventoryEventDelegate { get; }

        /// <summary>
        /// Gets ModifyFees.
        /// </summary>
        [Category("Fees")]
        public double ModifyFees
        {
            get
            {
                return this.modifyFees;
            }

            protected set
            {
                this.modifyFees = value > 0.0 ? value : 0.0;
            }
        }

        /// <summary>
        /// The order event delegate.
        /// </summary>
        public abstract OrderEventDelegate OrderEventDelegate { get; }

        #endregion
    }
}